<template>
  <div class="page">
    <div class="layui-fluid">
      <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
          <div class="layui-card">
            <div class="layui-card-body">
              <div class="layui-form" lay-filter="">
                
                <div class="layui-form-item" >
                  <label class="layui-form-label">开始时间</label>
                  <div class="layui-input-block" style="width: 190px;" id="test3">
                    <input type="text" name="createAt" placeholder="开始时间" autocomplete="off" class="layui-input a" disabled="disabled" /> 
                  </div>
                </div>
                <div class="layui-form-item" >
                  <label class="layui-form-label">结束时间</label>
                  <div class="layui-input-block" style="width: 190px;" id="test4">
                    <input type="text" name="finishAt" placeholder="开始时间" autocomplete="off" class="layui-input a" disabled="disabled" /> 
                  </div>
                </div>               
                <div class="layui-form-item">
                  <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="setmyinfo" @click="confirmOk"> 确认</button>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "taocantimeadd",
  data() {
    return {
     // dealerId: localStorage.getItem("dealerId"),
      projectId:'',//套餐活动id
      itemData: {       
        createAt:'',
        finishAt:'',
        shopId:localStorage.getItem("shopId"),      
      }
    }
  },
  mounted() {
    var _this = this;
    window.getdates = this.getdates;        
    layui.use('laydate', function () {
      var laydate = layui.laydate;
      laydate.render({
        elem: '#test3'
        , type: 'time'
        , done: function (value) {
          _this.itemData.createAt = value;
          // var value = getsjc(value);
        }
      });
      laydate.render({
        elem: '#test4'
        , type: 'time'
        , done: function (value) {
          _this.itemData.finishAt = value;
          // var value = getsjc(value);
          // alert(value);
        }
      });
    })    
    
  },
  methods: {
    getdates: function(data) {
      //回选详情
      var _this = this;
      _this.projectId= data.id;
      var url="/hotelinfo/aapi/v1.9/appointment-setting/"+ _this.projectId 
      ajaxRequest(url, "GET", "json", "", function(ret, err) {
//        alert("///"+JSON.stringify(ret))
        _this.itemData = ret.data;
        $("input[name='createAt']").val(FormatDate(ret.data.createAt,3));
        $("input[name='finishAt']").val(FormatDate(ret.data.finishAt,3));        
      });
    },   
    confirmOk: function() {
      var _this = this;      
      var createAt=$("input[name='createAt']").val();
      var finishAt=$("input[name='finishAt']").val(); 
      _this.itemData.createAt = getsjc(createAt);
      _this.itemData.finishAt = getsjc(finishAt);      	
      if (_this.projectId) {
        //编辑
        var hat = "PUT";                   
        var dates = {
        	id:_this.projectId,//api.pageParam.title.id,          
	        createAt:_this.itemData.createAt,	       
	        finishAt:_this.itemData.finishAt,	       	                                                               	        
        };        
      }
//        alert(JSON.stringify(dates))          
      var url = "/verify/bapi/v1.9/project";                                    
      ajaxRequest(url,hat,'json',dates,function(ret,err){               
        layer.msg("操作成功");
        setTimeout(function() {
          // _this.$router.push({ path: '/shopmallList' })
          var index = parent.layer.getFrameIndex(window.name);
          parent.layer.close(index);
          parent.location.reload();
        }, 1000);
      });
    }
  },
  updated: function() {
    var _this = this;
    layui.use("form", function() {
      var form = layui.form;
      form.render();         
      form.on("select(shopId)", function(data) {
        //门店
        _this.itemData.shopId = data.value;
      });
    });
  }
};
</script>
<style>
#J_imageView img {
  width: 400px;
  display: block;
}
.fllist ul {
  display: inline-block;
  width: 20%;
  height: 250px;
  margin-right: 1%;
  overflow: hidden;
  overflow-y: scroll;
  border: 1px solid #eee;
}
.fllist ul li {
  height: 30px;
  line-height: 30px;
  padding: 5px 20px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
.fllist ul li.cur {
  background-color: #3276df;
  color: #fff;
}
#demo2 img {
  display: inline-block;
  margin-right: 10px;
  width: 100px;
  height: 100px;
}
</style>
